from apps.model.baseModel import BaseModel
from comm.sqlalchemyConfig import db


class roleModel(BaseModel):
    """
    角色表
    """
    __tablename__ = 'tx_role'
    id = db.Column(db.String(100), primary_key=True, autoincrement=False,doc='id')
    name = db.Column(db.String(125), nullable=False,unique=True,doc='名称')
    rem = db.Column(db.Text, nullable=True, default='', doc='备注')

class rolePermissionModel(BaseModel):
    """
    角色具有的权限
    """
    __tablename__ = 'tx_role_permission'
    id = db.Column(db.String(100), primary_key=True, autoincrement=False,doc='id')
    permission_code = db.Column(db.String(100), db.ForeignKey('tx_permission.code'),doc='归属权限')
    role_id = db.Column(db.String(100), db.ForeignKey('tx_role.id'),doc='归属角色')

class roleUserModel(BaseModel):
    """
    角色包含哪些用户
    """
    __tablename__ = 'tx_role_user'
    id = db.Column(db.String(100), primary_key=True, autoincrement=False,doc='id')
    user_id = db.Column(db.String(100), db.ForeignKey('tx_users.id'),doc='归属用户')
    role_id = db.Column(db.String(100), db.ForeignKey('tx_role.id'),doc='归属角色')
